﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Categories.ascx.cs" Inherits="controls_admin_Categories" %>
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../Scripts/jquery.tablednd_0_5.js" type="text/javascript"></script>
<script type="text/javascript">
    var variable = "0";
    var j = jQuery.noConflict();
    j(document).ready(function () {
        j('#table-3').tableDnD({
            onDrop: function (table, row) {
                variable = j.tableDnD.serialize();
            }
        });
        j("#update").click(function () {
            j.ajax({
                type: "POST",
                url: "../services/Order.asmx/categories",
                data: "{'id':'&" + variable + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                beforeSend: function () {
                    j("#<%=divMessage.ClientID %>").html("");
                },
                success: function (message) {
                    if (message.d == false) {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>Lỗi</h6><span>Chưa thực hiện được!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                    }
                    else {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-success' class='message message-success'><div class='image'><img src='../resources/images/icons/success.png' alt='Success' height='32' /></div><div class='text'><h6>Thông Báo</h6><span>Cập nhật thành công !</span></div><div class='dismiss'><a href='#message-success'></a></div></div>");
                    }
                },
                error: function (errormessage) {
                    j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>Lỗi</h6><span>Chưa thực hiện được!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                }
            });
        });
    });
</script>
<!-- table -->
<div class="box">
    <!-- box / title -->
    <div class="title">
        <h5 runat="server" id="title">
            Danh mục</h5>
    </div>
    <div id="divMessage" runat="server">
    </div>
    <!-- end box / title -->
    <div class="table">
        <table id="table-3">
            <thead>
                <tr>
                    <th>
                        STT
                    </th>
                    <th>
                        Tên danh mục
                    </th>
                    <th>
                        Số mục con
                    </th>
                    <th>
                        Ngày tạo
                    </th>
                    <th>
                        Sửa
                    </th>
                    <th class="last">
                        Xóa
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="rptData" runat="server" OnItemCommand="rptData_ItemCommand" OnItemDataBound="rptData_ItemDataBound">
                    <ItemTemplate>
                        <tr id="<%#Eval("CATEGORY_ID") %>" style="cursor: move">
                            <td align="center">
                                <%#Container.ItemIndex+1%>
                            </td>
                            <td align="center">
                                <a id="aGoToChild" runat="server" href='<%#"~/Administrator/Default.aspx?module=Categories&c_id="+Eval("CATEGORY_ID")%>'>
                                    <%#Eval("FULL_CATEGORY_NAME")%></a>
                                <asp:Button ID="btnID" runat="server" CommandArgument='<%#Eval("CATEGORY_ID")%>'
                                    Visible="false" />
                            </td>
                            <td align="center">
                                <div id="divCountChild" runat="server" />
                            </td>
                            <td align="center">
                                <%#LibraryO2S.O2S_DateTime.dd_MM_yyyy(Convert.ToDateTime(Eval("CREATED_DATE")))%>
                            </td>
                            <%--<td align="center">
                                <asp:Button runat="server" ID="btnDisplay" CssClass="icon" CommandName='<%#Eval("CATEGORY_ID")%>'
                                    CommandArgument='<%#Eval("IS_DISPLAY_ON_HOME_PAGE")%>' BackColor="Transparent"
                                    BorderStyle="None" />
                            </td>--%>
                            <td align="center">
                                <a href='<%#"default.aspx?module=categoryedit&c_id="+Eval("CATEGORY_ID")%>' title="Chỉnh Sửa">
                                    <img src="../Resources/icons/16x16/edit.png" class="icon-32-edit" alt="Sửa" />
                                </a>
                            </td>
                            <td class="last" align="center">
                                <asp:Button runat="server" ID="btnDel" CssClass="icon-32-delete" CommandName="del"
                                    BackColor="Transparent" BorderStyle="None" OnClientClick="return confirm('Bạn có chắc chắn muốn xóa không ?');" />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
        <div class="action">
            <div class="button">
                <asp:Button ID="btnNew" runat="server" Text="Thêm Mới" OnClick="btnNew_Click" />
                <input type="button" value="Cập nhật thứ tự" id="update" />
            </div>
        </div>
    </div>
</div>
<!-- end table -->
